//   Copyright 2012,2013 Vaughn Vernon
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package com.saasovation.agilepm.domain.model.product.backlogitem;

import com.saasovation.agilepm.domain.model.ValueObject;

/**
 * @值对象：业务优先级总计
 */
public class BusinessPriorityTotals extends ValueObject {

    /**
     * 总收益
     */
    private int totalBenefit;
    /**
     * 总成本
     */
    private int totalCost;
    /**
     * 总罚款
     */
    private int totalPenalty;
    /**
     * 总风险
     */
    private int totalRisk;
    /**
     * 总计
     */
    private int totalValue;

    /**
     * 由以下参数构造业务优先级总计
     * @param aTotalBenefit     总收益
     * @param aTotalPenalty     总罚款
     * @param aTotalValue       总值
     * @param aTotalCost        总成本
     * @param aTotalRisk        总风险
     */
    public BusinessPriorityTotals(
            int aTotalBenefit,
            int aTotalPenalty,
            int aTotalValue,
            int aTotalCost,
            int aTotalRisk) {
        // 调用默认构造器
        this();

        this.setTotalBenefit(aTotalBenefit);
        this.setTotalCost(aTotalCost);
        this.setTotalPenalty(aTotalPenalty);
        this.setTotalRisk(aTotalRisk);
        this.setTotalValue(aTotalValue);
    }

    /**
     * 由已有的业务优先总计构造新业务优先总计
     * @param aBusinessPriorityTotals   业务优先总计
     */
    public BusinessPriorityTotals(BusinessPriorityTotals aBusinessPriorityTotals) {
        this(aBusinessPriorityTotals.totalBenefit(),
                aBusinessPriorityTotals.totalPenalty(),
                aBusinessPriorityTotals.totalValue(),
                aBusinessPriorityTotals.totalCost(),
                aBusinessPriorityTotals.totalRisk());
    }

    /**
     * 获取总收益
     * @return  返回总收益
     */
    public int totalBenefit() {
        return this.totalBenefit;
    }

    /**
     * 获取总成本
     * @return  返回总成本
     */
    public int totalCost() {
        return this.totalCost;
    }

    /**
     * 获取总罚款
     * @return 返回总罚款
     */
    public int totalPenalty() {
        return this.totalPenalty;
    }

    /**
     * 获取总风险
     * @return  返回总风险
     */
    public int totalRisk() {
        return this.totalRisk;
    }

    /**
     * 获取总值
     * @return  返回总值
     */
    public int totalValue() {
        return this.totalValue;
    }

    @Override
    public boolean equals(Object anObject) {
        boolean equalObjects = false;

        if (anObject != null && this.getClass() == anObject.getClass()) {
            BusinessPriorityTotals typedObject = (BusinessPriorityTotals) anObject;
            equalObjects =
                    this.totalBenefit() == typedObject.totalBenefit() &&
                            this.totalCost() == typedObject.totalCost() &&
                            this.totalPenalty() == typedObject.totalPenalty() &&
                            this.totalRisk() == typedObject.totalRisk() &&
                            this.totalValue() == typedObject.totalValue();
        }

        return equalObjects;
    }

    @Override
    public int hashCode() {
        int hashCodeValue =
                + (47091 * 19)
                        + this.totalBenefit()
                        + this.totalCost()
                        + this.totalPenalty()
                        + this.totalRisk()
                        + this.totalValue();

        return hashCodeValue;
    }

    @Override
    public String toString() {
        return "BusinessPriorityTotals [totalBenefit=" + totalBenefit + ", totalCost=" + totalCost + ", totalPenalty="
                + totalPenalty + ", totalRisk=" + totalRisk + ", totalValue=" + totalValue + "]";
    }

    /**
     * 默认构造器
     */
    private BusinessPriorityTotals() {
        // 调用父类默认构造器
        super();
    }

    /**
     * 设置总收益
     * @param aTotalBenefit 总收益
     */
    private void setTotalBenefit(int aTotalBenefit) {
        this.totalBenefit = aTotalBenefit;
    }

    /**
     * 设置总成本
     * @param aTotalCost    总成本
     */
    private void setTotalCost(int aTotalCost) {
        this.totalCost = aTotalCost;
    }

    /**
     * 设置总罚款
     * @param aTotalPenalty 总罚款
     */
    private void setTotalPenalty(int aTotalPenalty) {
        this.totalPenalty = aTotalPenalty;
    }

    /**
     * 设置总风险
     * @param aTotalRisk 总风险
     */
    private void setTotalRisk(int aTotalRisk) {
        this.totalRisk = aTotalRisk;
    }

    /**
     * 设置总值
     * @param aTotalValue   总值
     */
    private void setTotalValue(int aTotalValue) {
        this.totalValue = aTotalValue;
    }
}
